<%= form_tag(
      users_path,
      method: 'get',
      role: 'form',
      class: 'form-inline') do %>
  <div class="form-group">
    <%= text_field_tag :keyword, @keyword, class: 'form-control' %>
  </div>
  <%= submit_tag t("admin.search"), class: 'btn btn-primary' %>
  <%= submit_tag(
        t("admin.clear"),
        class: 'btn btn-danger',
        onclick: "location.href='#{users_path}';return false;") %>
<% end %>
<p><%= t "admin.user_search_hint" %></p>

<br/>

<%= paginate @users %>

<table class="table table-hover table-bordered table-striped table-condensed">
  <tr>
  	<th>Facebook</th>
  	<th><%= t "admin.name" %></th>
  	<th><%= t "admin.email" %></th>
  	<th><%= t "admin.address" %></th>
  	<th><%= t "admin.phone" %></th>
  	<th><%= t "admin.order" %></th>
  </tr>
  <% @users.each do |u| %>
  <tr>
  	<td align="center">
  		<%= render partial: "admin/user_fb", locals: {user: u} %>
  	</td>
  	<td><%= u.name %></td>
  	<td><%= u.email %></td>
  	<td><%= u.get_address_as_text %></td>
  	<td><%= u.phone %></td>
  	<td>
  	  <div><b><%= link_to "#{u.order_count} #{t('admin.order')}", orders_path(keyword: u.fb_id) %></b></div>

  	  <% order_counts_id = "order_counts_#{u.id.to_s}" %>
  	  <div id="<%= order_counts_id %>" style="display:none">
  	  	<% order_count_for_each_step = u.order_count_for_each_step %>
  	  	<% order_count_for_each_step.each do |step, count| %>
  		  <div><%= "#{count} #{Order.get_step_as_text step}" %></div>
  	  	<% end %>
  	  </div>
	  
  	  <button onclick="$('#<%= order_counts_id %>').toggle();return false;" class="btn btn-primary">
        <%= t "admin.see_more" %>
      </button>
  	</td>
  </tr>
  <% end %>
</table>

<%= paginate @users %>